/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.regressao.linear.modelo;

import br.com.regressao.linear.util.Util;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Objects;
import javax.persistence.AttributeOverride;
import javax.persistence.AttributeOverrides;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import org.hibernate.annotations.ForeignKey;

/**
 *
 * @author Rodrigo Moreira Alexandre
 * @author Fernando Aparecido Paulo
 */
@Entity
@Table(name = "item_eixo_y")
public class ItemEixoY implements Serializable, IModelo {

    @EmbeddedId
    @AttributeOverrides({
        @AttributeOverride(name = "eixoY", column = @Column(name = "ce_eixo_y", updatable = false)),
        @AttributeOverride(name = "identificador", column = @Column(name = "nr_identificador", updatable = false))
    })
    private ItemEixoYPK pK;
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "ce_eixo_y", updatable = false, insertable = false)
    @ForeignKey(name = "fk_eixo_y")
    private EixoY eixoY;
    @Column(name = "vl_eixo_y")
    private BigDecimal valorEixoY;

    public ItemEixoY() {
    }

    public ItemEixoY(ItemEixoYPK pK) {
        this.pK = pK;
    }
    
    public ItemEixoYPK getpK() {
        return pK;
    }

    public void setpK(ItemEixoYPK pK) {
        this.pK = pK;
    }

    public BigDecimal getValorEixoY() {
        return valorEixoY;
    }

    public void setValorEixoY(BigDecimal valorEixoY) {
        this.valorEixoY = valorEixoY;
    }

    public EixoY getEixoY() {
        return eixoY;
    }

    public void setEixoY(EixoY eixoY) {
        this.eixoY = eixoY;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 71 * hash + Objects.hashCode(this.pK);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final ItemEixoY other = (ItemEixoY) obj;
        if (!Objects.equals(this.pK, other.pK)) {
            return false;
        }
        return true;
    }


    @Override
    public Object getCodigo() {
        return pK;
    }

    @Override
    public boolean isInativo() {
        return false;
    }

     @Override
    public String toString() {
        return Util.NF_VALORES.format(valorEixoY.doubleValue());
    }
}
